﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NHAHANGLIENHOACHAY.SR_NHAHANG_BUS;
namespace NHAHANGLIENHOACHAY
{
    public partial class FormSuaKhuVuc : DevComponents.DotNetBar.Office2007Form
    {
        Service1SoapClient bus = new Service1SoapClient();
        public int trangthai = 0;
        //public string tenkv;
        //public string hinhthuckd;
        //public string mucgia;
        public FormSuaKhuVuc(string tenkv,string hinhthuckd,string mucgia,int makhuvuc)
        {

           
            InitializeComponent();
            txtTenKhuVuc.Text = tenkv;
            txtMucGiaChenhLech.Text = mucgia;
            cbbHinhThucKinhDanh.Text = hinhthuckd;
            lblMaKhuVuc.Text = makhuvuc.ToString();
        }

        private void FormThemKhuVuc_Load(object sender, EventArgs e)
        {
            HINHTHUCKD[] arrayhtkd;
            arrayhtkd = bus.LayDSHinhThucKinhDanh();
            cbbHinhThucKinhDanh.DataSource = arrayhtkd;
            cbbHinhThucKinhDanh.DisplayMember = "TenHinhThucKD";
            cbbHinhThucKinhDanh.ValueMember = "MaHinhThucKD";
        }

       
        private void bttHuyKhuVuc_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void bttSuaKhuVuc_Click(object sender, EventArgs e)
        {
            int maht = Int16.Parse(cbbHinhThucKinhDanh.SelectedValue.ToString());
            KHUVUC dto = new KHUVUC();
            dto.MaKhuVuc =Int16.Parse( lblMaKhuVuc.Text.ToString());
            dto.TenKhuVuc = txtTenKhuVuc.Text;
            dto.MucGiaChenhLech = Int16.Parse(txtMucGiaChenhLech.Text.ToString());
            if (bus.CapNhatKhuVuc(dto,maht))//Ham cập nhật
            {
                MessageBox.Show("Cập nhật thành công");
                this.Close();
                //FormMain frm = new FormMain();                
                //frm.Load_KhuVuc();
                trangthai = 1;
            }
            else
            {
                MessageBox.Show("Cập nhật thất bại");
            }
          
        }
    }
}
